package com.ttl.bc.ap.purchaseorder.bean;

import org.displaytag.decorator.TableDecorator;


public class BCPurchaseOrderSubShow2Decorator extends TableDecorator {
	
	public String getModeOLD() {		
		
		BCPurchaseOrderSubShow2Bean obj = (BCPurchaseOrderSubShow2Bean)getCurrentRowObject();
		String stkDocNo = obj.getStkReqNo();
		String poDocNo = obj.getDocNo();
		
		String 	print = "";
		String 	poCancel = "";
		String	poEdit = "";
		
		poEdit = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=edit&docNo="+stkDocNo+"&poDocNo="+poDocNo+"\">แก้ไข</a> | ";		
		poCancel = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=cancel&docNo="+stkDocNo+"&poDocNo="+poDocNo+"\">ยกเลิก</a> | ";					
		print = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=print&docNo="+poDocNo+"&stkDocNo="+stkDocNo+"\" target=\"_blank\">Print</a>";
												
		return "<center>"+poEdit+poCancel+print+"</center>";						
	}
	
	public String getMode() {		
		
		BCPurchaseOrderSubShow2Bean obj = (BCPurchaseOrderSubShow2Bean)getCurrentRowObject();
		String poDocNo = obj.getDocNo();						
		String stkDocNo = obj.getStkReqNo();
		Integer isCancel = obj.getIsCancel();
		
		String print = "";
		String po = "";
		if(isCancel==1) {
			po = "ยกเลิก";
		}else {
	//		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
	//			
	//			if(poDocNo!=null) {
	//				po =  "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=editPO&docNo="+stkDocNo+"&poDocNo="+poDocNo+"\">แก้ไข</a> | ";						
	//				po += "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=cancel&docNo="+stkDocNo+"&poDocNo="+poDocNo+"\">ยกเลิก</a> | ";			
					print = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=print&docNo="+poDocNo+"&stkDocNo="+stkDocNo+"\" target=\"_blank\">Print</a>";
	//			}
	//						
	//		}else if (obj.getIttl_status()!=null && (obj.getIttl_status().equals("2")||obj.getIttl_status().equals("3")) ) {
	//			po = "บันทึกอินวอยซ์แล้ว ";
	//			
	//		}else {
	//			po = "ยกเลิกขอซื้อ"+obj.getIttl_status();
	//		}
		}
		return "<center>"+po+print+"</center>";						
	}	
	
	public String getIttl_status() {
		
		BCPurchaseOrderSubShow2Bean obj = (BCPurchaseOrderSubShow2Bean)getCurrentRowObject(); 
		Integer isCancel = obj.getIsCancel();
		Integer poStatus = obj.getPoStatus();
		if(isCancel==1) {
			return "<center>"+"ยกเลิกใบ PO";
		}else if(poStatus ==0) {		
			return "<center>"+"อยู่ระหว่างการซื้อ";		
		}else if(poStatus ==2) {
			return "<center>"+"บันทึกซื้อแล้ว";
		}else {
			return "<center>"+"ค่าผิดพลาด";
		}
		
	}
}
